<!DOCTYPE HTML>
<title>autoplay overrides preload</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<div id=log></div>
<script>
['none', 'metadata'].forEach(function(preload) {
  ['first', 'last'].forEach(function(order) {
    async_test(function(t) {
      var a = document.createElement('audio');
      a.src = getAudioURI('/media/sound_5');
      if (order == 'first') {
        a.autoplay = true;
        a.preload = preload;
      } else {
        a.preload = preload;
        a.autoplay = true;
      }
      a.addEventListener('playing', t.step_func(function() {
        assert_equals(a.readyState, a.HAVE_ENOUGH_DATA);
        assert_false(a.paused);
        t.done();
      }));
    }, 'autoplay (set ' + order + ') overrides preload "' + preload + '"');
  });
});
</script>
